package eventplanner.rest.exceptionmappers;

import javax.persistence.NoResultException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;

@Provider
public class RestNoResultExceptionHandler implements ExceptionMapper<NoResultException> {

	private static final String ERROR_MESSAGE = "The entity could not be found";

	@Override
	public Response toResponse(NoResultException e) {
		return Response.status(Response.Status.NOT_FOUND).type(MediaType.TEXT_PLAIN_TYPE).entity(ERROR_MESSAGE).build();
	}
}
